home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / xdme_1.84_src.lha / XDME / Src / filereq.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-22  |  17.9 KB  |  800 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     $Id: filereq.c 1.2 1994/09/09 12:31:30 digulla Exp digulla $
  5.  
  6.     DESCRIPTION
  7.     All routines that handle file-requesters. We try to open ASL and
  8.     if that's not possible, REQTOOLS.
  9.  
  10.     HISTORY
  11.     28. Nov 1992    ada created
  12.     $Log: filereq.c $
  13.  * Revision 1.2  1994/09/09  12:31:30  digulla
  14.  * added new style Prototypes, DEFCMD and DEFHELP
  15.  *
  16.  * Revision 1.1  1994/08/14  12:30:15  digulla
  17.  * Initial revision
  18.  *
  19.  
  20. ******************************************************************************/
  21.  
  22. /**************************************
  23.         Includes
  24. **************************************/
  25. #include "defs.h"
  26. #include <clib/reqtools_protos.h>
  27. #include <proto/reqtools.h>
  28. #include <proto/asl.h>
  29.  
  30.  
  31. /**************************************
  32.         Globale Variable
  33. **************************************/
  34. Prototype struct FileRequester     * FReq;
  35. Prototype struct ReqToolsBase     * ReqToolsBase;
  36. Prototype struct rtFileRequester * RFReq;
  37.  
  38. struct FileRequester   * FReq;      /* File-Req. structure */
  39. struct rtFileRequester * RFReq;
  40. struct ReqToolsBase    * ReqToolsBase;
  41.  
  42.  
  43. /**************************************
  44.       Interne Defines & Strukturen
  45. **************************************/
  46.  
  47.  
  48. /**************************************
  49.         Interne Variable
  50. **************************************/
  51. Prototype char pattern[];
  52. char pattern[64] = "";
  53. static char file[108];
  54. static char dir[PATHSIZE];
  55.  
  56.  
  57. /**************************************
  58.        Interne Prototypes
  59. **************************************/
  60.  
  61.  
  62. /*DEFHELP #cmd prefs,io,requester PATTERN pat - sets the pattern for the filerequesters. */
  63.  
  64. DEFUSERCMD("pattern", 1, CF_VWM|CF_COK|CF_ICO, void, do_pattern, (void),)
  65. {
  66.     strncpy (pattern, av[1], 63);
  67.     pattern[63] = 0;
  68. }
  69.  
  70.  
  71. /*DEFHELP #cmd requester,io ARPLOAD - NEWFILE with filerequester */
  72.  
  73. DEFUSERCMD("arpload", 0, CF_VWM, void, do_aslload, (void),)
  74. {
  75.     BPTR oldlock;
  76.     BOOL ret;
  77.  
  78.     oldlock = CurrentDir (Ep->dirlock);
  79.  
  80.     splitpath (Ep->name, file, dir);
  81.  
  82. DEFMESSAGE( __unnamed, "unnamed" )
  83.     if (!stricmp (file, __unnamed))
  84.     *file = 0;
  85.  
  86.     fixdirname (dir);
  87.  
  88.     if (AslBase)
  89.     {               /* If we have asl.library & requester */
  90.     if (!FReq)
  91.         FReq = AllocAslRequest (ASL_FileRequest, NULL);
  92.  
  93.     if (!FReq)
  94.     {
  95.         nomemory ();
  96.         return;
  97.     }
  98.  
  99.     ret = AslRequestTags ((APTR)FReq,
  100. DEFMESSAGE( _REQ_load_new_file, "XDME Load New File" )
  101.         ASL_Hail,    _REQ_load_new_file,
  102. DEFMESSAGE( _REQ_ok_load, "Load" )
  103.         ASL_OKText,    _REQ_ok_load,
  104.         ASL_Window,    Ep->win,
  105.         ASL_FuncFlags,    FILF_NEWIDCMP | FILF_PATGAD,
  106.         ASL_Dir,    dir,
  107.         ASL_File,    file,
  108.         ASL_Pattern,    pattern,
  109.         ASL_LeftEdge,    Ep->config.aslleft + Ep->win->LeftEdge,     /* use config coords */
  110.         ASL_TopEdge,    Ep->config.asltop + Ep->win->TopEdge,
  111.         ASL_Width,    Ep->config.aslwidth,
  112.         ASL_Height,    Ep->config.aslheight,
  113.         TAG_DONE
  114.     );
  115.  
  116.     Ep->config.asltop    = FReq->rf_TopEdge - Ep->win->TopEdge;     /* save coords */
  117.     Ep->config.aslleft   = FReq->rf_LeftEdge - Ep->win->LeftEdge;
  118.     Ep->config.aslwidth  = FReq->rf_Width;
  119.     Ep->config.aslheight = FReq->rf_Height;
  120.  
  121.     if (ret)
  122.     {
  123.         BPTR newlock;
  124.  
  125.         if ((newlock = Lock (FReq->rf_Dir, SHARED_LOCK)))
  126.         {
  127.         BPTR cd = CurrentDir (oldlock);
  128.  
  129.         Ep->dirlock = (long)newlock;
  130.  
  131.         strcpy (pattern, FReq->rf_Pat);
  132.  
  133.         av[0] = (UBYTE *)"n";
  134.         av[1] = (UBYTE *) FReq->rf_File;
  135.  
  136.         if (do_edit () == -1)
  137.         {
  138.             Ep->dirlock = (long)cd;
  139.             UnLock (newlock);
  140.         }
  141.         else
  142.             UnLock (cd);
  143.         }
  144.     } else
  145.     {
  146.         SETF_ABORTCOMMAND(Ep,1);
  147.         CurrentDir (oldlock);
  148.     }
  149.     } else
  150.     {           /* no asl.library? try reqtools */
  151.     do_reqload ();
  152.     }
  153. } /* do_aslload */
  154.  
  155.  
  156. Prototype int aslsave (void);
  157.  
  158. int aslsave (void)
  159. {
  160.     BPTR oldlock = CurrentDir (Ep->dirlock);
  161.     BOOL ret;
  162.  
  163.     splitpath (Ep->name, file, dir);
  164.  
  165. DEFMESSAGE( __unnamed, "unnamed" )
  166.     if (!stricmp (file, __unnamed))
  167.     *file = 0;
  168.  
  169.     fixdirname (dir);
  170.  
  171.     if (AslBase)
  172.     {
  173.     if (!FReq)
  174.         FReq = AllocAslRequest (ASL_FileRequest, NULL);
  175.  
  176.     if (!FReq)
  177.     {
  178.         nomemory ();
  179.         return (FALSE);
  180.     }
  181.  
  182. loop:
  183.     ret = AslRequestTags( (APTR)FReq,
  184. DEFMESSAGE( _REQ_save_file, "XDME Save File" )
  185.         ASL_Hail,    _REQ_save_file,
  186. DEFMESSAGE( _REQ_save_ok, "Save" )
  187.         ASL_OKText,    _REQ_save_ok,
  188.         ASL_Window,    Ep->win,
  189.         ASL_FuncFlags,    FILF_NEWIDCMP | FILF_SAVE,
  190.         ASL_Dir,    dir,
  191.         ASL_File,    file,
  192.         ASL_LeftEdge,    Ep->config.aslleft + Ep->win->LeftEdge,     /* use config coords */
  193.         ASL_TopEdge,    Ep->config.asltop + Ep->win->TopEdge,
  194.         ASL_Width,    Ep->config.aslwidth,
  195.         ASL_Height,    Ep->config.aslheight,
  196.         TAG_DONE
  197.     );
  198.  
  199.     Ep->config.asltop    = FReq->rf_TopEdge - Ep->win->TopEdge;     /* save coords */
  200.     Ep->config.aslleft   = FReq->rf_LeftEdge - Ep->win->LeftEdge;
  201.     Ep->config.aslwidth  = FReq->rf_Width;
  202.     Ep->config.aslheight = FReq->rf_Height;
  203.  
  204.     if (ret)
  205.     {
  206.         BPTR tmp_lock;
  207.  
  208. DEFMESSAGE( __unnamed, "unnamed" )
  209.         if (!stricmp (FReq->rf_File, __unnamed))
  210.         {
  211. DEFMESSAGE( _REQ_cant_saveas_unnamed, "%s:\nCannot save file as\n`unnamed'" )
  212.         error (_REQ_cant_saveas_unnamed, av[0], __unnamed);
  213.         *file = 0;
  214.         goto loop;
  215.         }
  216.  
  217.         CurrentDir (oldlock);
  218.  
  219.         strcpy (file, FReq->rf_File);
  220.         strcpy (dir, FReq->rf_Dir);
  221.         strcpy (pattern, FReq->rf_Pat);
  222.  
  223.         if (!*file)
  224.         {
  225. DEFMESSAGE( _REQ_a_name_is_needed, "%s:\nYou must specify a name" )
  226.         error (_REQ_a_name_is_needed, av[0]);
  227.         goto loop;
  228.         }
  229.  
  230.         AddPart (dir, file, PATHSIZE);
  231.  
  232.         av[1] = (UBYTE *)dir;
  233.  
  234.         if ((tmp_lock = Lock (dir, ACCESS_READ)))
  235.         {
  236.         UnLock (tmp_lock);
  237.  
  238. DEFMESSAGE( __xdme_warning, "XDME Warning" )
  239.         if (!getyn ("XDME Warning",
  240. DEFMESSAGE( _REQ_file_exists_overwrite, "The file\n`%s'\ndoes already exist.Do you want to overwrite it ?" )
  241.             _REQ_file_exists_overwrite,
  242. DEFMESSAGE( __ok_cancel, "Yes|No" )
  243.             __ok_cancel, dir) )
  244.             return (FALSE);
  245.         }
  246.  
  247.         return (do_saveas ());
  248.     } else
  249.     {
  250.         SETF_ABORTCOMMAND(Ep,1);
  251.         CurrentDir (oldlock);
  252.     }
  253.     } else
  254.     {
  255.     return (do_reqsave ());
  256.     }
  257.  
  258.     return (FALSE);
  259. } /* aslsave */
  260.  
  261.  
  262. /*DEFHELP #cmd requester,io ARPINSFILE - INSFILE with filerequester */
  263.  
  264. DEFUSERCMD("arpinsfile", 0, 0, void, do_aslinsfile, (void),)
  265. {
  266.     BPTR oldlock = CurrentDir (Ep->dirlock);
  267.     BOOL ret;
  268.  
  269.     splitpath (Ep->name, file, dir);
  270.  
  271. DEFMESSAGE( __unnamed, "unnamed" )
  272.     if (!stricmp (file, __unnamed))
  273.     *file = 0;
  274.  
  275.     fixdirname (dir);
  276.  
  277.     if (AslBase)
  278.     {
  279.     if (!FReq)
  280.         FReq = AllocAslRequest (ASL_FileRequest, NULL);
  281.  
  282.     if (!FReq)
  283.     {
  284.         nomemory ();
  285.         return;
  286.     }
  287.  
  288.     ret = AslRequestTags ((APTR)FReq,
  289. DEFMESSAGE( _REQ_insert_file, "XDME Insert File" )
  290.         ASL_Hail,    _REQ_insert_file,
  291. DEFMESSAGE( _REQ_ok_insert, "Insert" )
  292.         ASL_OKText,    _REQ_ok_insert,
  293.         ASL_Window,    Ep->win,
  294.         ASL_FuncFlags,    FILF_NEWIDCMP | FILF_PATGAD,
  295.         ASL_Dir,    dir,
  296.         ASL_File,    file,
  297.         ASL_Pattern,    pattern,
  298.         ASL_LeftEdge,    Ep->config.aslleft + Ep->win->LeftEdge,     /* use config coords */
  299.         ASL_TopEdge,    Ep->config.asltop + Ep->win->TopEdge,
  300.         ASL_Width,    Ep->config.aslwidth,
  301.         ASL_Height,    Ep->config.aslheight,
  302.         TAG_DONE );
  303.  
  304.     Ep->config.asltop    = FReq->rf_TopEdge - Ep->win->TopEdge;     /* save coords */
  305.     Ep->config.aslleft   = FReq->rf_LeftEdge - Ep->win->LeftEdge;
  306.     Ep->config.aslwidth  = FReq->rf_Width;
  307.     Ep->config.aslheight = FReq->rf_Height;
  308.  
  309.     if (ret)
  310.     {
  311.         CurrentDir (oldlock);
  312.  
  313.         /* Fields are READ-ONLY */
  314.         strcpy (file, FReq->rf_File);
  315.         strcpy (dir, FReq->rf_Dir);
  316.         strcpy (pattern, FReq->rf_Pat);
  317.  
  318.         AddPart (dir, file, PATHSIZE);
  319.  
  320.         av[0] = (UBYTE *)"i";
  321.         av[1] = (UBYTE *)dir;
  322.  
  323.         do_edit ();
  324.     } else
  325.     {
  326.         SETF_ABORTCOMMAND(Ep,1);
  327.         CurrentDir (oldlock);
  328.     }
  329.     } else
  330.     {
  331.     do_reqinsfile ();
  332.     }
  333. } /* do_aslinsfile */
  334.  
  335.  
  336. /*DEFHELP #cmd requester,font ARPFONT - SETFONT with fontrequester */
  337.  
  338. DEFUSERCMD("arpfont", 0, CF_VWM, void, do_aslfont, (void),)
  339. {
  340.     if (AslBase)
  341.     {
  342.     struct FontRequester *fontreq;
  343.  
  344. #ifdef _DCC
  345.     ULONG fwin = (ULONG)Ep->win;  /* put ASL on correct screen */
  346. #endif
  347.  
  348.     struct TagItem FontTags[] =
  349.     {   /* DICE 2.06.37 allows us to initialize this here... */
  350. #ifdef _DCC
  351.         ASL_Window,     fwin,
  352.         ASL_LeftEdge,   Ep->config.aslleft + Ep->win->LeftEdge,    /* use config coords */
  353.         ASL_TopEdge,    Ep->config.asltop + Ep->win->TopEdge,
  354.         ASL_Hail,        (ULONG)_REQ_fixed_width_font,
  355. #else
  356.         ASL_Window,     0L,
  357.         ASL_LeftEdge,   0L,
  358.         ASL_TopEdge,    0L,
  359.         ASL_Hail,        0L,
  360. #endif
  361.         ASL_FuncFlags,  FILF_NEWIDCMP | FONF_FIXEDWIDTH,
  362.         /* Removed Min & MaxHeight since I cannot figure out what the
  363.            user may want */
  364.         TAG_DONE
  365.     };
  366.  
  367. #ifndef _DCC
  368.     FontTags[0].ti_Data = (ULONG)Ep->win;
  369.     FontTags[1].ti_Data = Ep->config.aslleft + Ep->win->LeftEdge;
  370.     FontTags[2].ti_Data = Ep->config.asltop + Ep->win->TopEdge;
  371. DEFMESSAGE( _REQ_fixed_width_font, "XDME fixed width font" )
  372.     FontTags[3].ti_Data = (ULONG)_REQ_fixed_width_font;
  373. #endif
  374.  
  375.     if ((fontreq = (struct FontRequester *)
  376.                 AllocAslRequest (ASL_FontRequest,FontTags) ))
  377.     {
  378.  
  379.         if (AslRequest (fontreq, NULL))
  380.         {
  381.  
  382.         /*  Since we have GetFont() already, just pass
  383.          *   the name and size from fontreq's TextAttr to it.
  384.          *
  385.          *  What follows mimics SETFONT (in cmnd3.c)
  386.          */
  387.  
  388.         FONT * font = (FONT *)GetFont( fontreq->fo_Attr.ta_Name,
  389.                          (short) fontreq->fo_Attr.ta_YSize );
  390.         ED * ep = Ep;
  391.  
  392.         if (font)
  393.         {
  394.             if (ep->font)
  395.             CloseFont (ep->font);
  396.  
  397.             ep->font = font;
  398.  
  399.             SetFont (ep->win->RPort, font);
  400.             SetRast (ep->win->RPort, 0);
  401.  
  402.             RefreshWindowFrame (ep->win);
  403.  
  404.             set_window_params ();
  405.  
  406.             text_adjust (TRUE);
  407.         } else
  408.         {
  409. DEFMESSAGE( _REQ_cant_find_font, "%s:\nUnable to find font\n%s/%ld" )
  410.             error (_REQ_cant_find_font, av[0], fontreq->fo_Attr.ta_Name,
  411.                fontreq->fo_Attr.ta_YSize);
  412.         }
  413.         }
  414.         else
  415.         SETF_ABORTCOMMAND(Ep,1);
  416.  
  417.         FreeAslRequest (fontreq);
  418.     }
  419.     else
  420.     {
  421.         nomemory ();
  422.     }
  423.     } else
  424.     {
  425.     do_reqfont ();
  426.     }
  427. } /* do_aslfont */
  428.  
  429.  
  430. /*  this little kludge gets a DIR: string for the ASL requester
  431.  */
  432.  
  433. Prototype void fixdirname (char * dir);
  434.  
  435. void fixdirname (char * dir)
  436. {
  437.     if (!strlen (dir))
  438.     {              /* if no DIR; KLUDGE ALERT! */
  439.     if (NameFromLock (Ep->dirlock, dir, PATHSIZE)!=DOSTRUE)
  440.     {
  441.         dir[0] = 0; /* assumes NameFromLock doesn't clean up on err(??) */
  442.     }
  443.     }
  444. } /* fixdirname */
  445.  
  446.  
  447. /*
  448.  *  Search backwards for first ':' or '/' and split path there.
  449.  *  This subroutine may appear to be coded incorrectly to a novice
  450.  *  programmer.  It isn't [now].
  451.  */
  452.  
  453. Prototype void splitpath (char * name, char * file, char * dir);
  454.  
  455. void splitpath (char * name, char * file, char * dir)
  456. {
  457.     int i;
  458.  
  459.     strcpy (file, FilePart (name));
  460.  
  461.     i = (long)PathPart (name) - (long)name;
  462.  
  463.     movmem (name, dir, i);
  464.     dir[i] = 0;
  465. } /* splitpath */
  466.  
  467.  
  468. /*
  469.  *  The REQ interface uses the reqtools.library if it exists, else tries to
  470.  *  use the ARP interfafce.
  471.  */
  472.  
  473. /*DEFHELP #cmd requester,io REQLOAD - NEWFILE with ReqTools filerequester */
  474.  
  475. DEFUSERCMD("reqload", 0, CF_VWM, void, do_reqload, (void),)
  476. {
  477.     BPTR oldlock = CurrentDir (Ep->dirlock);
  478.  
  479.     splitpath (Ep->name, file, dir);
  480.  
  481. DEFMESSAGE( __unnamed, "unnamed" )
  482.     if (!stricmp (file, __unnamed))
  483.     *file = 0;
  484.  
  485.     fixdirname (dir);
  486.  
  487.     if (ReqToolsBase)
  488.     {             /* If we have req.library & requester */
  489.     if (!RFReq)
  490.         RFReq = rtAllocRequestA (RT_FILEREQ, NULL);
  491.  
  492.     if (!RFReq)
  493.     {
  494.         nomemory ();
  495.         return;
  496.     }
  497.  
  498.     rtChangeReqAttr (RFReq, RTFI_Dir, dir, TAG_DONE);
  499.  
  500. DEFMESSAGE( _REQ_load_new_file, "XDME Load New File" )
  501.     if (rtFileRequest (RFReq, file, _REQ_load_new_file,
  502. DEFMESSAGE( _REQ_ok_load, "Load" )
  503.         RTFI_OkText,    _REQ_ok_load,
  504.         RT_Window,    Ep->win,
  505.         RT_ReqPos,    REQPOS_TOPLEFTSCR,
  506.         RT_LeftOffset,    Ep->config.aslleft,
  507.         RT_TopOffset,    Ep->config.asltop,
  508.         RTFI_Height,    Ep->config.aslheight,
  509.         TAG_DONE ))
  510.         {
  511.         BPTR newlock;
  512.  
  513.         if ((newlock = Lock (RFReq->Dir, SHARED_LOCK)))
  514.         {
  515.         BPTR cd = CurrentDir (oldlock);
  516.  
  517.         Ep->dirlock = (long)newlock;
  518.  
  519.         strcpy (dir, RFReq->Dir);
  520.         AddPart (dir, file, PATHSIZE);
  521.  
  522.         av[0] = (UBYTE *)"n";
  523.         av[1] = (UBYTE *) file;
  524.  
  525.         if (do_edit () == -1)
  526.         {
  527.             Ep->dirlock = (long)cd;
  528.             UnLock (newlock);
  529.         }
  530.         else
  531.             UnLock (cd);
  532.         }
  533.     } else
  534.     {
  535.         SETF_ABORTCOMMAND(Ep,1);
  536.         CurrentDir (oldlock);
  537.     }
  538.     } else
  539.     {           /* no req.library? Gulp */
  540.     if (AslBase)
  541. DEFMESSAGE( _REQ_try_arp, "%s:\nNo ReqTools.Library\nTry ARP equivalent" )
  542.         error (_REQ_try_arp, av[0]);
  543.     else
  544. DEFMESSAGE( _REQ_need_req_or_asl, "For filerequester,\nI need REQ- or ASL.LIBRARY !" )
  545.         error (_REQ_need_req_or_asl);
  546.     }
  547. } /* do_reqload */
  548.  
  549.  
  550. Prototype int reqsave (void);
  551.  
  552. int reqsave (void)
  553. {
  554.     BPTR oldlock = CurrentDir(Ep->dirlock);
  555.  
  556.     splitpath (Ep->name, file, dir);
  557.  
  558. DEFMESSAGE( __unnamed, "unnamed" )
  559.     if (!stricmp (file, __unnamed))
  560.     *file = 0;
  561.  
  562.     fixdirname (dir);
  563.  
  564.     if (ReqToolsBase)
  565.     {             /* If we have req.library & requester */
  566.     if (!RFReq)
  567.         RFReq = rtAllocRequestA (RT_FILEREQ, NULL);
  568.  
  569.     if (!RFReq)
  570.     {
  571.         nomemory ();
  572.         return (FALSE);
  573.     }
  574.  
  575.     rtChangeReqAttr (RFReq, RTFI_Dir, dir, TAG_DONE);
  576.  
  577. loop:
  578. DEFMESSAGE( _REQ_save_file, "XDME Save File" )
  579.     if (rtFileRequest (RFReq, file, _REQ_save_file,
  580. DEFMESSAGE( _REQ_save_ok, "Save" )
  581.         RTFI_OkText,    _REQ_save_ok,
  582.         RT_Window,    Ep->win,
  583.         RTFI_Flags,    FREQF_SAVE,
  584.         RT_ReqPos,    REQPOS_TOPLEFTSCR,
  585.         RT_LeftOffset,    Ep->config.aslleft,
  586.         RT_TopOffset,    Ep->config.asltop,
  587.         RTFI_Height,    Ep->config.aslheight,
  588.         TAG_DONE ))
  589.     {
  590.         BPTR tmp_lock;
  591.  
  592. DEFMESSAGE( __unnamed, "unnamed" )
  593.         if (!stricmp (file, __unnamed))
  594.         {
  595. DEFMESSAGE( _REQ_cant_saveas_unnamed, "%s:\nCannot save file as\n`unnamed'" )
  596.         error (_REQ_cant_saveas_unnamed, av[0], __unnamed);
  597.         goto loop;
  598.         }
  599.  
  600.         CurrentDir (oldlock);
  601.  
  602.         strcpy (dir, RFReq->Dir);
  603.         AddPart (dir, file, PATHSIZE);
  604.  
  605.         if (!*file)
  606.         {
  607. DEFMESSAGE( _REQ_a_name_is_needed, "%s:\nYou must specify a name" )
  608.         error (_REQ_a_name_is_needed, av[0]);
  609.         goto loop;
  610.         }
  611.  
  612.         av[1] = (UBYTE *)dir;
  613.  
  614.         if ((tmp_lock = Lock (dir, ACCESS_READ)))
  615.         {
  616.         UnLock (tmp_lock);
  617.  
  618. DEFMESSAGE( __xdme_warning, "XDME Warning" )
  619.         if (!getyn (__xdme_warning,
  620. DEFMESSAGE( _REQ_file_exists_overwrite, "The file\n`%s'\ndoes already exist.Do you want to overwrite it ?" )
  621.             _REQ_file_exists_overwrite,
  622. DEFMESSAGE( __ok_cancel, "Yes|No" )
  623.             __ok_cancel, dir) )
  624.             return (FALSE);
  625.         }
  626.  
  627.         return (do_saveas ());
  628.     } else
  629.     {
  630.         SETF_ABORTCOMMAND(Ep,1);
  631.         CurrentDir (oldlock);
  632.     }
  633.     } else
  634.     {
  635.     if (AslBase)
  636. DEFMESSAGE( _REQ_try_arp, "%s:\nNo ReqTools.Library\nTry ARP equivalent" )
  637.         error (_REQ_try_arp, av[0]);
  638.     else
  639. DEFMESSAGE( _REQ_need_req_or_asl, "For filerequester,\nI need REQ- or ASL.LIBRARY !" )
  640.         error (_REQ_need_req_or_asl);
  641.     }
  642.  
  643.     return (FALSE);
  644. } /* reqsave */
  645.  
  646.  
  647. /*DEFHELP #cmd requester,io REQINSFILE - INSFILE with ReqTools filerequester */
  648.  
  649. DEFUSERCMD("reqinsfile", 0, 0, void, do_reqinsfile, (void),)
  650. {
  651.     BPTR oldlock = CurrentDir (Ep->dirlock);
  652.  
  653.     splitpath (Ep->name, file, dir);
  654.  
  655. DEFMESSAGE( __unnamed, "unnamed" )
  656.     if (!stricmp (file, __unnamed))
  657.     *file = 0;
  658.  
  659.     fixdirname (dir);
  660.  
  661.     if (ReqToolsBase)
  662.     {             /* If we have req.library & requester */
  663.     if (!RFReq)
  664.         RFReq = rtAllocRequestA (RT_FILEREQ, NULL);
  665.  
  666.     if (!RFReq)
  667.     {
  668.         nomemory ();
  669.         return;
  670.     }
  671.  
  672.     rtChangeReqAttr (RFReq, RTFI_Dir, dir, TAG_DONE);
  673.  
  674. DEFMESSAGE( _REQ_insert_file, "XDME Insert File" )
  675.     if (rtFileRequest (RFReq, file, _REQ_insert_file,
  676. DEFMESSAGE( _REQ_ok_insert, "Insert" )
  677.         RTFI_OkText,    _REQ_ok_insert,
  678.         RT_ReqPos,    REQPOS_TOPLEFTSCR,
  679.         RT_Window,    Ep->win,
  680.         RT_LeftOffset,    Ep->config.aslleft,
  681.         RT_TopOffset,    Ep->config.asltop,
  682.         RTFI_Height,    Ep->config.aslheight,
  683.         TAG_DONE ))
  684.     {
  685.  
  686.         CurrentDir (oldlock);
  687.  
  688.         strcpy (dir, RFReq->Dir);
  689.         AddPart (dir, file, PATHSIZE);
  690.  
  691.         av[0] = (UBYTE *)"i";
  692.         av[1] = (UBYTE *)file;
  693.  
  694.         do_edit ();
  695.     } else
  696.     {
  697.         SETF_ABORTCOMMAND(Ep,1);
  698.         CurrentDir (oldlock);
  699.     }
  700.     } else
  701.     {
  702.     if (AslBase)
  703. DEFMESSAGE( _REQ_try_arp, "%s:\nNo ReqTools.Library\nTry ARP equivalent" )
  704.         error (_REQ_try_arp, av[0]);
  705.     else
  706. DEFMESSAGE( _REQ_need_req_or_asl, "For filerequester,\nI need REQ- or ASL.LIBRARY !" )
  707.         error (_REQ_need_req_or_asl, av[0]);
  708.     }
  709. } /* do_reqinsfile */
  710.  
  711.  
  712. /*DEFHELP #cmd requester,io REQFONT - SETFONT with ReqTools fontrequester */
  713.  
  714. DEFUSERCMD("reqfont", 0, CF_VWM, void, do_reqfont, (void),)
  715. {
  716.     if (ReqToolsBase)
  717.     {
  718.     struct rtFontRequester *fontreq;
  719.  
  720. #ifdef _DCC
  721.     struct Window *fwin = Ep->win;    /* put ASL on correct screen */
  722. #endif
  723.  
  724.     struct TagItem FontTags[] =
  725.     {   /* DICE 2.06.37 allows us to initialize this here... */
  726. #ifdef _DCC
  727.         RT_Window,        fwin,
  728. #else
  729.         RT_Window,        NULL,
  730. #endif
  731.         RTFO_MinHeight, 6,
  732.         RTFO_MaxHeight, 24,
  733.         RTFO_Flags,     FREQF_FIXEDWIDTH, /* | FILF_NEWIDCMP */
  734.         TAG_DONE };
  735.  
  736. #ifndef _DCC
  737.         FontTags[0].ti_Data = (ULONG)Ep->win;
  738. #endif
  739.  
  740.     if ((fontreq = rtAllocRequestA (RT_FONTREQ, NULL)))
  741.     {
  742. DEFMESSAGE( _REQ_fixed_width_font, "XDME fixed width font" )
  743.         if (rtFontRequestA (fontreq, _REQ_fixed_width_font, FontTags))
  744.         {
  745.  
  746.         /*  Since we have GetFont() already, just pass
  747.          *   the name and size from fontreq's TextAttr to it.
  748.          *
  749.          *  What follows mimics SETFONT (in cmnd3.c)
  750.          */
  751.  
  752.         FONT * font = (FONT *)GetFont (fontreq->Attr.ta_Name,
  753.                          (short) fontreq->Attr.ta_YSize );
  754.         ED   * ep   = Ep;
  755.  
  756.         if (font)
  757.         {
  758.             if (ep->font)
  759.             CloseFont (ep->font);
  760.  
  761.             ep->font = font;
  762.  
  763.             SetFont (ep->win->RPort, font);
  764.             SetRast (ep->win->RPort, 0);
  765.  
  766.             RefreshWindowFrame (ep->win);
  767.             set_window_params ();
  768.  
  769.             text_adjust (TRUE);
  770.         } else
  771.         {
  772. DEFMESSAGE( _REQ_cant_find_font, "%s:\nUnable to find font\n%s/%ld" )
  773.             error (_REQ_cant_find_font, av[0], fontreq->Attr.ta_Name,
  774.                fontreq->Attr.ta_YSize);
  775.         }
  776.         }
  777.         else
  778.         SETF_ABORTCOMMAND(Ep,1);
  779.  
  780.         rtFreeRequest (fontreq);
  781.     } else
  782.     {
  783.         nomemory ();
  784.     }
  785.     } else
  786.     {
  787.     if (AslBase)
  788. DEFMESSAGE( _REQ_try_arp, "%s:\nNo ReqTools.Library\nTry ARP equivalent" )
  789.         error (_REQ_try_arp, av[0]);
  790.     else
  791. DEFMESSAGE( _REQ_font_need_req_or_asl, "For fontrequester,\nI need REQ- or ASL.LIBRARY !" )
  792.         error (_REQ_font_need_req_or_asl);
  793.     }
  794. } /* do_reqfont */
  795.  
  796.  
  797. /******************************************************************************
  798. *****  ENDE filereq.c
  799. ******************************************************************************/
  800.